/*
 * Treatment.java
 *
 * Created on April 25, 2009, 10:04 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package Project.bussiness;

import Project.DBHelper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

/**
 *
 * @author Hao Hao
 */
public class Treatment {
    
    private int TreatID;
    private int CaseID;
    private int DoctorID;
    private String BedID;
    private String Reason;
    private String Date;
    
    /** Creates a new instance of Treatment */
    public Treatment() {
    }

    public int getTreatID() {
        return TreatID;
    }

    public void setTreatID(int TreatID) {
        this.TreatID = TreatID;
    }

    public int getCaseID() {
        return CaseID;
    }

    public void setCaseID(int CaseID) {
        this.CaseID = CaseID;
    }

    public int getDoctorID() {
        return DoctorID;
    }

    public void setDoctorID(int DoctorID) {
        this.DoctorID = DoctorID;
    }

    public String getBedID() {
        return BedID;
    }

    public void setBedID(String BedID) {
        this.BedID = BedID;
    }

    public String getReason() {
        return Reason;
    }

    public void setReason(String Reason) {
        this.Reason = Reason;
    }

    public String getDate() {
        return Date;
    }

    public void setDate(String Date) {
        this.Date = Date;
    }
    
    public static int insertTreatment(Treatment t) throws SQLException
    {
        int i;
        try{
            Vector paramList = new Vector();
            paramList.add(t.CaseID);
            paramList.add(t.DoctorID);
            paramList.add(t.BedID);
            paramList.add(t.Reason);
            paramList.add(t.Date);
            i=DBHelper.executeUpdate("spInsertTreatment",paramList);
        } catch(SQLException e)
        {
            throw e;
        }
        return i;
    }
    
    public static Vector getAllTreatmentByCaseID(int caseid) throws SQLException
    {
        Vector v = new Vector();
        try {
            Vector paramList = new Vector();
            paramList.add(new Integer(caseid));
        ResultSet rs = DBHelper.executeQuery("spGetAllTreatmentByCaseID",paramList);
            while(rs.next()){
                Treatment tm = new Treatment();
                tm.setTreatID(rs.getInt(1));
                tm.setCaseID(rs.getInt(2));
                tm.setDoctorID(rs.getInt(3));
                tm.setBedID(rs.getString(4));
                tm.setReason(rs.getString(5));
                tm.setDate(rs.getString(6));
                v.add(tm);
            }
        } catch(SQLException sqle) {
            throw sqle;
        }
        return v;        

    }
}
